package odgs.message.client;

import java.util.List;

import odgs.Connection;
import odgs.ContentsFile;
import odgs.Transaction;
import odgs.message.Message;
import odgs.message.MessageHandler;
import odgs.message.MessageProcessor;
import odgs.transaction.ContentsGetTransaction;
import odgs.transaction.ExecuteTransction;

public class ContentsGetTransactionResponseHandler implements MessageHandler
{
	public void execute(MessageProcessor processor, Message msg, Connection con)
	{
		if(msg.getResult() < 0)
		{
			Transaction tran = (Transaction) msg.get("transaction");
			processor.getTransactionManager().error(msg.getResult(), tran);
		}
		else
		{
			List<ContentsFile> files = (List<ContentsFile>) msg.get("files");
			ContentsGetTransaction tran = (ContentsGetTransaction) msg.get("transaction");
			tran = (ContentsGetTransaction) processor.getTransactionManager().getTransaction(tran.getRequestId());
			processor.getTransactionManager().receiveFile(files, tran);
		}
	}
}